import socket
friend_list={'alex':'32','太白':'33'}


sk=socket.socket(type=socket.SOCK_DGRAM)
sk.bind(('127.0.0.1',9001))
while True:
    msg,addr=sk.recvfrom(1024)
    msg=msg.decode('utf-8')
    name,message=msg.split('|')

    print(name,'*****',message)
    print('\033[1;%sm %s:%s\033'%(friend_list.get(name,'30'),name,message))
    content=input('>>>>')

    sk.sendto(content.encode('utf-8'),addr)
    if content.upper()=='Q':break
























